package com.biz.primus.ms.adv.dao.repository;

import com.biz.primus.ms.adv.dao.po.Advertisement;
import com.biz.primus.ms.base.jpa.repository.CommonJpaRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

/**
 * @author: jun.liu
 * @date 2017-09-18
 */
public interface AdvertisementRepository extends CommonJpaRepository<Advertisement, Long>{ //, AdvertisementDao {

    @Query("select ad from Advertisement ad order by ad.createTimestamp desc")
    Page<Advertisement> findAll(Pageable page);

    @Query("select ad from Advertisement ad where ad.adPosition.id = ?1 order by ad.createTimestamp desc")
    Page<Advertisement> findAll(Long id, Pageable page);
}
